// 导出功能类型定义

// PDF导出选项
export interface PDFExportOptions {
  format: 'A4' | 'A3' | 'Letter';
  orientation: 'portrait' | 'landscape';
  margins: {
    top: number;
    right: number;
    bottom: number;
    left: number;
  };
  fontSize: number;
  fontFamily: string;
  includeMetadata: boolean;
  watermark?: string;
  quality: 'low' | 'medium' | 'high';
}

// Word导出选项
export interface WordExportOptions {
  template: 'standard' | 'formal' | 'creative';
  fontSize: number;
  fontFamily: string;
  lineSpacing: number;
  margins: {
    top: number;
    right: number;
    bottom: number;
    left: number;
  };
  includeTableOfContents: boolean;
  headerFooter?: {
    header?: string;
    footer?: string;
  };
}

// 导出历史项
export interface ExportHistoryItem {
  id: string;
  filename: string;
  format: 'pdf' | 'word';
  timestamp: number;
  size: number;
  options: PDFExportOptions | WordExportOptions;
}

// 导出模板
export interface ExportTemplate {
  id: string;
  name: string;
  format: 'pdf' | 'word';
  isDefault: boolean;
  options: PDFExportOptions | WordExportOptions;
  createdAt: number;
  updatedAt: number;
}

// 导出结果
export interface ExportResult {
  success: boolean;
  filename?: string;
  size?: number;
  error?: string;
}

// 导出进度
export interface ExportProgress {
  stage: 'preparing' | 'converting' | 'generating' | 'saving' | 'completed';
  progress: number; // 0-100
  message: string;
}

// 导出服务接口
export interface ExportService {
  exportToPDF(content: string, options: PDFExportOptions, filename?: string): Promise<ExportResult>;
  exportToWord(content: string, options: WordExportOptions, filename?: string): Promise<ExportResult>;
  previewExport(content: string, format: 'pdf' | 'word', options: any): Promise<string>;
  getExportHistory(): Promise<ExportHistoryItem[]>;
  saveExportTemplate(template: ExportTemplate): Promise<void>;
  getExportTemplates(format?: 'pdf' | 'word'): Promise<ExportTemplate[]>;
  deleteExportTemplate(templateId: string): Promise<void>;
}

// 默认导出选项
export const DEFAULT_PDF_OPTIONS: PDFExportOptions = {
  format: 'A4',
  orientation: 'portrait',
  margins: {
    top: 20,
    right: 20,
    bottom: 20,
    left: 20
  },
  fontSize: 12,
  fontFamily: 'SimSun, serif',
  includeMetadata: true,
  quality: 'medium'
};

export const DEFAULT_WORD_OPTIONS: WordExportOptions = {
  template: 'standard',
  fontSize: 12,
  fontFamily: 'SimSun',
  lineSpacing: 1.5,
  margins: {
    top: 25.4,
    right: 25.4,
    bottom: 25.4,
    left: 25.4
  },
  includeTableOfContents: false
};

// 存储键定义
export const EXPORT_STORAGE_KEYS = {
  PDF_SETTINGS: 'rmzf:export:pdf:settings',
  WORD_SETTINGS: 'rmzf:export:word:settings',
  EXPORT_HISTORY: 'rmzf:export:history',
  CUSTOM_TEMPLATES: 'rmzf:export:templates'
} as const;